import { FC, memo, Suspense } from 'react'
import { useRoutes } from 'react-router-dom'

import routes from './router'

interface IState {
  children?: React.ReactNode
}

const App: FC<IState> = memo((props) => {
  // 初始化设置主题
  const theme = localStorage.getItem('theme') || 'theme-light'
  document.documentElement.setAttribute('class', theme)

  return (
    <div className="mian">
      <Suspense fallback="">{useRoutes(routes)}</Suspense>
    </div>
  )
})

export default App
